<template>
  <div>
    <!-- 面包导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/admin' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>留言管理</el-breadcrumb-item>
      <el-breadcrumb-item>留言列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图区域 -->
    <el-card style="margin-left:-1rem;margin-top:1rem">
      <el-row :gutter="20">
        <el-col :span="8">
          <el-input placeholder="请输入内容"  clearable @clear="getUserList">
            <el-button slot="append" icon="el-icon-search" ></el-button>
          </el-input>
        </el-col>
      </el-row>

      <!-- 用户列表区域 -->
      <el-table :data="Userlist" border stripe style="margin-top:1rem">
        <el-table-column label="＃" type="index"></el-table-column>
        <el-table-column label="用户" prop="name"></el-table-column>
        <el-table-column label="留言图书" prop="bname"></el-table-column>
        <el-table-column label="留言时间" prop="time"></el-table-column>
        <el-table-column label="留言内容" prop="names"></el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <!-- <el-button type="primary" icon="el-icon-edit" size="mini"></el-button> -->
            <el-button type="danger" icon="el-icon-delete" size="mini" @click="del(scope.row.id)"></el-button>
 
            <!-- <el-tooltip effect="dark" content="分配角色" placement="top" :enterable="false">
              <el-button type="warning" icon="el-icon-setting" size="mini"></el-button>
            </el-tooltip> -->
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>    

<script>
import { setToken, setUserName } from "../../utils/auth";
import request from "../../utils/request";
export default {
  data(){
      return{
        //控制添加用户对话框的显示喝隐藏
         addVisible:false,
          Userlist:[],

      }
  },
  mounted() {
    // 加载列表
    this.getUserList();
  },
  methods: {
    getUserList() {
      request({
        url: "/api/user/getcomment",
        method: "post",
        data: {}
      }).then(res => {
      console.log(res)
       this.Userlist = res.list
        
      });
    },
    del(id){
        request({
          url: "/api/user/getcommentdel",
          method: "post",
          data: {id:id}
        }).then(res => {
          location.reload();
          
        });
    }
  }
}
</script>

<style lang="less" scoped>
</style>